package net.jcip.examples.vehicles.point;

public class ImmutablePoint implements Point {

    private final double x;
    private final double y;

    public double getX() {
        return x;
    }

    @Override
    public void setX(double x) {
        throw new UnsupportedOperationException();
    }

    public double getY() {
        return y;
    }

    @Override
    public void setY(double y) {
        throw new UnsupportedOperationException();
    }

    @Override
    public double[] get() {
        return new double[] { x, y };
    }

    @Override
    public void set(double x, double y) {
        throw new UnsupportedOperationException();
    }

    public ImmutablePoint(double x, double y) {
        this.x = x;
        this.y = y;
    }

    public ImmutablePoint(Point point) {
        this(point.getX(), point.getY());
    }

    @Override
    public Object clone() {
        return new ImmutablePoint(x, y);
    }

}
